import { LazyLoader } from "@sapi-game/gameComponent/common/lazyLoader";
import { EntityInteractionListener } from "@/base/components/playerInteractListener";
import { Region } from "@sapi-game/main";
import { DimensionIds } from "@sapi-game/utils/vanila-data";
import { HubGameComponent } from "./components/hubGames";
import { baseModule } from "./module";
import { HubArmorStandProtecter } from "./components/armorStandProtect";

//大厅的State
export class HubState extends baseModule.State {
    readonly region = new Region.SphereRegion(
        DimensionIds.Overworld,
        { x: 444, y: 4, z: 444 },
        64
    );

    override onEnter(): void {
        this.addComponent(LazyLoader, {
            dimensionId: DimensionIds.Overworld,
            pos: { x: 444, y: 4, z: 444 },
            onLoad: this.onLoad.bind(this),
        });
    }

    onLoad(loader: LazyLoader) {
        loader
            .addComponent(EntityInteractionListener)
            .addComponent(HubGameComponent)
            .addComponent(HubArmorStandProtecter);
    }
}
